<template>
  <div>
    子组件B
    {{ myObj }}

    <el-button type="primary" @click="print" size="small">执行父组件方法</el-button>
  </div>
</template>
<script>
export default {
  name: 'B',
  props: {
    myObj: {
      type: Object,
      default: () => {
      }
    }
  },

  created() {
    console.log(this.myObj)

    this.$on('doSomething', (args) => {
      console.log('监听到了:', args)
    })
  },
  methods: {
    print() {
      console.log('print')
      this.$emit('doSomething', {msg: 'this is a book', name: 'jack', age: 25})
    },
  },
}
</script>
